<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!Doctype html>
<html>
<head>
    <meta content="text/html" charset="utf-8">
    <title>党建</title>
    <meta name="keywords" content="务川,党建"/>
    <meta name="description" content="务川,党建"/>
    <link href="../../static/images/ico/favicon.png" rel="shortcut icon">
    <link rel="stylesheet" type="text/css" href="../../static/css/article.css">
    <link rel="stylesheet" type="text/css" href="../../static/css/bootstrap.css">

    <script type="text/javascript" src="../../static/js/user/jq181.js"></script>
    <script type="text/javascript" src="../../static/js/user/article.js"></script>
    <script type="text/javascript" src="../../static/js/user/vote.js"></script>

    <style>
        .row{
            margin-top: 6px;
        }
        .col-xs-4{
            overflow: hidden;
        }
        .col-xs-4 img{
            height: 130px;
        }
    </style>
    <c:if test="${flag==false}">
        <script type="text/javascript">
            alert("亲爱的用户，你没有投票的权限");
            window.location.href="/vote/index.do";
        </script>
    </c:if>
    <script>

        $(function(){
            var vote = new Vote("#voteForm", ${vote.min}, ${vote.max});
            $("#submitBtn").click(function(){
                var data = vote.checkAndGetDate();
                //成功
                if(data.status)
                {
                    //alert(data.data);
                    $.ajax({
                        type: "POST",
                        url: data.url,
                        data: data.data,
                        success: function(msg){
                            alert( msg.status);
                        }
                    });
                }
                else
                {
                    alert(data.msg)
                }
                return false;
            });

        });

    </script>
</head>
<body>
<jsp:include page="../../themes/header.jsp"/>
<div id="middle">
    <div class="wrapper">
        <div id="middle-content">
            <div class="article-wrapper">
                <div class="article-header">
                    <div>
                        <span></span>当前位置：<a href="/index.do">首页</a> &gt; <a href="/vote/content.do">投票</a>
                    </div>
                </div>
                <div class="article-content-wrapper">
                    <h2>投票系统</h2>
                    <p class="article-info">
                        <%--<span>2014-11-10</span>--%>
                        <span>亲爱的用户：${sessionScope.sysUser.realname}</span>
                    </p>

                    <div class="article-content">
                        <form role="form" id="voteForm" action="/vote/saveSelect.do">
                            <div class="row">
                                <div class="col-xs-3">
                                </div>
                                <div class="col-xs-7">
                                    <p style="margin-bottom: 20px;">
                                        <c:choose>
                                            <c:when test="${vote.isover==0}">
                                                <button id="submitBtn" class="btn bg-primary btn-block">投票</button>
                                            </c:when>
                                            <c:otherwise>
                                                <h2 style="color: red">
                                                    此投票已关闭，不能在进行投票
                                                </h2>
                                            </c:otherwise>
                                        </c:choose>
                                    </p>
                                </div>
                            </div>
                            <div class="row">

                                <input type="hidden" name="voteid" value="${vote.id}"/>
                                <c:forEach var="item" items="${list}">
                                    <div class="col-xs-4">
                                        <div>
                                            <c:choose>
                                                <c:when test="${not empty item.url}">
                                                    <img id="portrait" src="${item.url}" width="120px" height="120px">
                                                </c:when>
                                                <c:otherwise>
                                                    <img id="portrait" src="../../static/images/default.gif" width="120px" height="120px">
                                                </c:otherwise>
                                            </c:choose>
                                        </div>
                                        <br/>
                                        <p>姓名:<span style="color: red">${item.title}</span></p>
                                        <p>票数:<span style="color: red">${item.votes}</span></p>

                                        <c:choose>
                                            <c:when test="${vote.isover==0}">
                                                <p>投票:<input name="voteName" value="${item.id}" type="checkbox"></p>
                                            </c:when>
                                            <c:otherwise>
                                                <p>投票系统已关闭</p>
                                            </c:otherwise>
                                        </c:choose>
                                    </div>
                                </c:forEach>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../../themes/footer.jsp"/>
</body>
</html>